const request=require('../../utils/request.js');//获取封装的请求函数
const globleurl = require('../../utils/serverconfig.js').url;
Page({

  data: {
    movieinfo:{},
    value:'',
    nodataurl:globleurl+'/images/nodata.png',
    shownodata:true
  },

  onLoad: function (options) {
    let value=options.value;
    this.setData({
      value
    })
    this.search();
  },


    async search(){
      let movieinfo=await request.myrequest('/miniapp/searchmovie',{value:this.data.value});
      console.log(movieinfo);
      if(movieinfo.data.length==0){
        this.setData({
          shownodata:true
        });
      }else{
        movieinfo.data[0].img_url=globleurl+movieinfo.data[0].img_url;
        this.setData({
          movieinfo:movieinfo.data[0],
          shownodata:false
        })
      }
    

    },

    
    buy(){
      wx.switchTab({
        url: '../cinema/cinema',
      })
    },

})